package day3;


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Scanner;

public
class TestScanner {
    private InputStream is;

    public TestScanner(InputStream is) {
        this.is = is;
        isr=new InputStreamReader(is);
        br=new BufferedReader(isr);
    }
    private InputStreamReader isr;
    private BufferedReader br;
    public String next() {
        try {
            return br.readLine();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
    public int nextInt(){
        try {
            int result=Integer.parseInt(br.readLine());
            return result;
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
    public static
    void main(String[] args) throws IOException {
        //System.in 表示系统输入流 他可以获取控制台输入的数据 本质上是一个字节输入流
        //Scanner sc=new Scanner(System.in);
        TestScanner ts=new TestScanner(System.in);
        //sc.nextLine() sc.next()
        InputStream is=System.in;
        InputStreamReader isr=new InputStreamReader(is);
        BufferedReader br=new BufferedReader(isr);
        while (true){
            System.out.println("请输入：");
            System.out.println("读取控制台数据为："+br.readLine());
        }
    }
}
class TestScanner2{
    public static
    void main(String[] args) {
        TestScanner ts=new TestScanner(System.in);
        System.out.println("请输入姓名：");
        String name=ts.next();
        System.out.println("请输入年龄：");
        int age=ts.nextInt();
        System.out.println(name);
        System.out.println(age);
    }
}